<template>
  <div class="login-panel">
    <h2>后台管理系统</h2>
    <el-tabs type="border-card" stretch>
      <el-tab-pane>
        <template #label>
          <span class="layout">
            <el-icon>
              <UserFilled />
            </el-icon>
            <span>账号登录</span>
          </span>
        </template>
        <account-login ref="accountRef" />
      </el-tab-pane>
      <el-tab-pane>
        <template #label>
          <span class="layout">
            <el-icon>
              <Iphone />
            </el-icon>
            <span>手机登录</span>
          </span>
        </template>
        <phone-login :title="'标题林'" />
      </el-tab-pane>
      <div class="layout-sb select">
        <el-checkbox v-model="isKeepPassword" label="记住密码" />
        <div>忘记密码</div>
      </div>
      <div class="layout-end">
        <el-button type="primary" siez="small" @click="handlerLogin">登录</el-button>
      </div>
    </el-tabs>
  </div>
</template>

<script lang="ts">
import { defineComponent, ref } from "vue"
import accountLogin from "./account-login.vue"
import phoneLogin from "./phone-login.vue"
export default defineComponent({
  components: { accountLogin, phoneLogin },
  setup() {
    const isKeepPassword = ref(true)
    // 获取组件的类型 （InstanceType<typeof 组件名称>>）
    const accountRef = ref<InstanceType<typeof accountLogin>>()

    const handlerLogin = () => {
      // 调用子组件的方法
      accountRef.value?.accoutLogin(isKeepPassword.value)
    }

    return {
      isKeepPassword,
      handlerLogin,
      accountRef
    }
  }
})
</script>

<style lang="less" scoped>
.login-panel {
  text-align: center;
  width: 30%;
  margin-bottom: 120px;
  background-color: #fff;
  h2 {
    padding: 20px 0;
  }
  .el-tabs {
    height: 300px;
  }
  .select {
    color: #7abbff;
    padding-left: 20px;
    padding-bottom: 20px;
    div {
      cursor: pointer;
    }
  }
  .el-button {
    width: 30%;
    height: 40px;
  }
}
</style>
